<?php
	case 'insert':
		if(empty($_REQUEST['areaname']))show("请填写地区名称");
		$len = strlen($_REQUEST['areaname']);
		if($len < 2 || $len > 300)show("地区名必须在2个至30个字符之间");
		$areaname  = trim($_REQUEST['areaname']);
		$areaname = trim(preg_replace("/(\s*(\r\n|\n\r|\n|\r)\s*)/", "\r\n", $areaname));
		$areaarray	= explode("\r\n",$areaname);
		$parentid  = intval($_REQUEST['parentid']);
		$areaorder = intval($_REQUEST['areaorder']);

		if(empty($areaorder)) {
			$sql = "SELECT MAX(areaorder) FROM {$table}area";
			$maxorder = $db->getOne($sql);
			$areaorder = $maxorder + 1;
		}
		foreach($areaarray as $value){
			$sql = "INSERT INTO {$table}area (areaname,parentid,areaorder) VALUES ('$value','$parentid','$areaorder')";
			$res = $db->query($sql);
			$areaorder = $areaorder + 1;
			clear_caches('phpcache');
			admin_log("插入地区 $value 成功");
		}
		show('添加地区成功','area.php?act=add');
	break;

?>


create table if not exists `qidi_flag` (
	`id`		int(12) unsigned not null auto_increment,
	`name`	varchar(50) default '' comment '名称',
	`label`	varchar(50) default '' comment '标示',
	`value`	int(8) default '0' comment 'flag值：2的指数。（如：0：1，1：2,2：4，3：8，4：16）',
	`table`	varchar(50) default '' comment '',
	`created`	int(12) default '0' comment '创建时间',
	`updated`	int(12) default '0' comment '更新时间',
	`status`	tinyint(2) default '1' comment '状态',
	primary key(`id`)
) engine=myisam default charset=utf8 auto_increment=1;



